package com.shsxt.crm.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.shsxt.crm.dao.YgCustomerLossDao;
import com.shsxt.crm.model.YgCustomerLoss;
import com.shsxt.crm.service.ICustomerLossService;

@Service
public class CustomerLossServiceImpl implements ICustomerLossService {

	@Autowired
	private YgCustomerLossDao ygCustomerLossDao;

	@Override
	public Map<String, Object> queryCustomerLossesByParams(YgCustomerLoss ygCustomerLoss) {

		PageHelper.startPage(ygCustomerLoss.getPage(), ygCustomerLoss.getRows());
		// 查询数据
		List<YgCustomerLoss> list = ygCustomerLossDao.findYgCustomerLoss(ygCustomerLoss);
		// 组装分页参数
		PageInfo<YgCustomerLoss> info = new PageInfo<>(list);

		Map<String, Object> map = new HashMap<>();
		map.put("total", info.getTotal());
		map.put("rows", info.getList());
		return map;
	}

	@Override
	public YgCustomerLoss queryCustomerLossById (Integer lossId) {
		return ygCustomerLossDao.get(lossId);
	}

}
